#ifndef ODN_GAMESTATE_H
#define ODN_GAMESTATE_H

#include "ODN_GameMgr.h"
#include "ODN_GameTimer.h"
#include "ODN_InputDevice.h"
#include "ODN_Singleton.h"

namespace ouden {

//Interface for a game state
//Derive different game states from this class and override the functions to determine its behaviour
class CGameState : public IGameTimerListener, public IInputReceiver
{
public:

	//First event called by game manager is passed a pointer to the game manager for access later and redirects
	// to the overridden enter() function in the derived game state class
	//TODO: Remove this function
	//void init(CGameManager* pGameManager) 		{ m_pGameManager = pGameManager; enter(); }

	//Events called by a game manager
	virtual void enter()								= 0;
	virtual void exit()									= 0;
	virtual void pause()								= 0;
	virtual void resume()								= 0;

	virtual bool frameEnded()							= 0;
	/*
	//TODO: Remove because derived and not implemented
	//IGameTimerListener functions
	virtual bool onTick(CGameTimer* pTimer)		 		= 0;
	virtual bool onFrameStart(CGameTimer* pTimer) 		= 0;

	//IInputReceiver functions
	virtual void onKeyPress(KeyCode iKey)				= 0;
	virtual void onKeyDown(KeyCode iKey)				= 0;
	virtual void onKeyUp(KeyCode iKey)					= 0;
	virtual void onUnBufInput(IInputDevice* pInput) 	= 0;
	*/
protected:

	CGameState() 		{}
	virtual ~CGameState() 		{}

	//void changeState(CGameManager* pGameManager, CGameState* pGameState) { pGameaManager->changeState(pGameState); }
	//void pushState(CGameManager* pGameManager, CGameState* pGameState) { pGameManager->pushState(pGameState); }
	//void popState(CGameManager* pGameManager) { pGameManager->popState(); }

	void changeState(CGameState* pGameState) 		{ CGameMgr::getInstance()->changeState(pGameState); }
	void pushState(CGameState* pGameState) 			{ CGameMgr::getInstance()->pushState(pGameState); }
	void popState() 								{ CGameMgr::getInstance()->popState(); }

private:

};

} //namespace ouden

#endif //ODN_GAMESTATE_H
